<?php
	require_once('../../lib/'.'BaseDir.inc.htm');		
	require_once(EIU_CLASS.'IOClass.htm');		
	require_once(EIU_CLASS.'Category.htm');		
	require_once(EIU_LIB.'DBCommon.class.htm');	
	
	//Thử nghiệm MySQL RollBack
	$oDB = new DBCommon();
	$conn =  $oDB->stl_openConn();
	
	$q1 = "
		INSERT INTO `qltbv2`.`status_tbl` (`STAID`, `STAName`, `DescriptionSta`, `isDeleted`, `CreateDate`, `LastUpdate`, `ModifiedBy`) 
		VALUES (NULL, 'Test 1', '', '', '', CURRENT_TIMESTAMP, '');
	";
	
	$q2 = "
		INSERT INTO `qltbv2`.`status_tbl` (`STAID`, `STAName`, `DescriptionSta`, `isDeleted`, `CreateDate`, `LastUpdate`, `ModifiedBy`) 
		VALUES (19, 'Test 2', '', '', '', CURRENT_TIMESTAMP, '');
	";
	
	$commit = "commit";
	$rollback = "rollback";
	$begin = "begin";
	
	$rs_1 = $oDB->stl_db_change($begin, $conn);
	$rs_2 = $oDB->stl_db_change($q1, $conn);
	$rs_3 = $oDB->stl_db_change($q2, $conn);	
	
	
	echo $rs_1."<br>";
	echo $rs_2."<br>";
	echo $rs_3."<br>";
	echo $rs_4."<br>";
	
	if($rs_2 != "OK" || $rs_3 != "OK")
	{
		echo $rollback;
		$rs_4 = $oDB->stl_db_change($rollback, $conn);
	}
	else
	{
		echo $commit;
		$rs_4 = $oDB->stl_db_change($commit, $conn);
	}
	
	$oDB->stl_closeConn($conn);
	
?>

